/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package persistence;

import java.util.Iterator;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import vo.rb_vendor;

/**
 *
 * @author Shuhail
 */
public class rb_vendor_persist {
    Session sess=null;
    Transaction tx=null;
    
    public static rb_vendor_persist getInstance() {
        
        return new rb_vendor_persist();
    }
    
    public rb_vendor_persist() {
        
     SessionFactory sf=new Configuration().configure().buildSessionFactory();
     sess=sf.openSession();
     tx=sess.beginTransaction();
    }
    
    public List<rb_vendor> fetch() {
        Query query=sess.getNamedQuery("fetchAllVendors");
        List list=query.list();
        Iterator it=list.iterator();
        while(it.hasNext()){
            
            rb_vendor vendor_new=(rb_vendor)it.next();
           // System.out.println(vendor_new.getVendor_name());
            
        }
       return list;
    }
    
}
